﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Http;

namespace AirlineServer.Controllers
{
    public class JetStarController : ApiController
    {
        // GET: /JetStar/
        
        public List<List<Flight>> Get(string structure,string depCity,string depTime,string arrCity,string arrTime,string currency,string ADT,string CHD,string INFANT)
        {
            //Create info
            Info info = new Info();
            info._FlightStructure = structure;
            info._DepartCity = depCity;
            info._DepartDay = depTime;
            info._ArriveCity = arrCity;
            info._ArriveDay = arrTime;
            info._Currency = currency;
            info._ADT = ADT;
            info._CHD = CHD;
            info._INFANT = INFANT;

            //Find
            List<List<Flight>> flights = new List<List<Flight>>();
            string html = JetStarSearch.GetResponseStream(info);
            List<Flight> departflights = JetStarSearch.SearchFlight(html);
            List<Flight> returnflights = new List<Flight>();
            if(info._FlightStructure == "RoundTrip")
                returnflights = JetStarSearch.SearchReturnFlight(html);
            flights.Add(departflights);
            flights.Add(returnflights);
            return flights;
        }

    }
}
